package org.frvi.goldspring.business.dao;

import org.frvi.goldspring.business.entity.Account;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * This needs to move to an abstract base class that contains the sessionfactory, much cleaner
 * Date: Oct 6, 2009
 * Time: 11:44:28 PM
 * To change this template use File | Settings | File Templates.
 */
@Repository("accountDao")
@Transactional
public class AccountDaoImpl extends AbstractHibernateDaoImpl<Account> implements AccountDao {
    public Account findByName(String name) {
        return (Account) getSessionFactory()
                .getCurrentSession()
                .getNamedQuery(Account.FIND_BY_NAME)
                .setString("name", name)
                .uniqueResult();
    }

    @Override
    protected Class getDomainObject() {
        return Account.class;
    }
}
